<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace' => 'Frontend\V10', 'prefix' => 'v10', 'middleware' => 'app_important_maintain'], function () {
    Route::group(['namespace' => 'Auth'], function () {
        //注册
//        Route::post('register', 'RegisterController@register')->name('api_v10.register');
        Route::post('webRegister', 'RegisterController@webRegister')->name('api_v10.webRegister');
        Route::post('sms', 'RegisterController@sms');
        Route::post('webSms','RegisterController@webSms');
        Route::get('img-code','RegisterController@createImgCode');
        Route::post('verify-img-code','RegisterController@verifyImgCode');
        Route::post('web-verify-code','RegisterController@webVerifyCode');
        //登录
//        Route::post('login', 'LoginController@login')->name('api_v10.login');
        //注销
//        Route::get('logout', 'LoginController@logout');
        /**
         * 微信绑定已有用户
         */
        Route::post('bindPhone', 'LoginController@bindingPhone');
        Route::post('bindPass', 'LoginController@bindingPass');

    });


    /**
     * 用户模块路由
     */
    Route::group(['namespace' => 'Users'], function () {
        // 获取用户基础信息
//        Route::get('me', 'UserController@me');
        Route::get('captcha', 'UserController@getCaptcha');
        //验证图片验证码
        Route::post('verifyImageCode','UserController@verifyImageCode');
        //用户修改密码前发送短信用来验证用户短信签收是否正常
        Route::get('smsUser/{phoneNum}', 'UserController@smsUser');
        //验证用户短信验证码和图片验证码
        Route::post('verifySms', 'UserController@verifySms');
        //验证用户身份证号码
        Route::post('verifyCertNum', 'UserController@verifyCert');
        //用户修改密码
        Route::patch('modifyPass', 'UserController@modifyPass');
        //临时简化帮用户修改密码,不安全，慎用
//        Route::patch('tempTestModifyPass', 'UserController@tempTestModifyPass');
        //用户上传头像
        Route::post('uploadAvatar', 'UserController@uploadAvatar');

        //用户在线修改密码
        Route::patch('modifyPassword','UserController@modifyPassword');
        /**
         * 用户基础信息
         */
        Route::apiResource('userInfo', 'UserInfoController')->only(['store']);
        Route::get('get-info-cache','UserInfoController@getInfoCache');
        /**
         * 用户身份证ORC
         */
        Route::post('ocr/cert','UserOcrController@cert');
        Route::apiResource('userOcr', 'UserOcrController')->only(['store']);
        Route::get('userOcr/getInfo','UserOcrController@getInfo');
        /**
         * 用户人脸识别
         */
        Route::apiResource('userFace','UserFaceController')->only(['store']);
        Route::get('userFaceLimit','UserFaceController@checkFaceLimit')->name('face.limit');
        Route::post('user-face-fail','UserFaceController@failedLog')->name('face.fail');
        Route::post('face-skip','UserFaceController@faceSkip')->name('face.skip');
        Route::get('face-success','UserFaceController@checkSuccess')->name('face.cache');
        /**
         * 手机运营商认证
         */
        Route::apiResource('userPhoneService','UserPhoneServiceController')->only(['store']);
        /**
         * 芝麻信用认证
         */
        Route::apiResource('userZhiMa','UserZhiMaController')->only(['store']);

        /**
         * 选择银行卡
         */
        Route::post('chooseCashCard','UserChooseCashCardController@store');

        /**
         * 选择信用卡
         */
        Route::post('chooseCreditCard','UserChooseCreditCardController@store');

        /**
         * 微信相关
         */
        Route::apiResource('wechat','UserWechatsController')->only(['store', 'update', 'show']);
    });
    /**
     * 银行卡路由
     */
    Route::group(['namespace' => 'BankCard'], function () {
        //申请绑定，发送短信
        Route::post('applyBindCard', 'BindCardController@applyBindCard');
        //绑定确认
        Route::post('bindCardConfirm', 'BindCardController@bindCardConfirm');
        //获取当前用户银行卡列表
        Route::get('getCardList/{card_type?}/{loan?}','CardInfoController@getCardList');
        //获取银行卡信息
        Route::get('getCardNum/{id}','CardInfoController@getCardNum');
        //用户换卡
        Route::post('changeCard','BindCardController@changeCard');

        Route::get('bank_list', 'BindCardController@bankList')->name('bank.list');
        // 获取银行编码和是否是信用卡
        Route::post('queryBankCode', 'BindCardController@queryBankCode');

        //热门推荐信用卡
        Route::get('recommend_credit_cards','RecommendCreditCardController@index');

    });
    /**
     * 财务模块路由
     */
    Route::group(['namespace' => 'Financial'], function () {
        Route::apiResource('loan', 'LoanController')->only(['store']);
        Route::post('loanRequestApply','LoanController@loanRequestApply');
        Route::get('loanInfoBefore','LoanController@getLoanInfoBeforeApply');
       //购买保险
        Route::get('loanPurchaseInsurance','LoanController@loanPurchaseInsurance');
        //申请放款
        Route::post('applyLoan','LoanApplyController@applyLoan');
        //获取放款非成功的结果
        Route::post('loanStatus','LoanApplyController@loanStatus');
        //放款失败确认
        Route::post('loanFailConfirm','LoanApplyController@failConfirm');



        /**
         * 获取当前状态的借款申请信息
         */
        Route::get('loanInfo','LoanController@getLoanDetail');

        /**
         * 借款申请失败处理
         */
        Route::post('loan/reset','LoanController@resetHandler');

        /**
         * 借款记录
         */
        Route::get('loan-record','LoanController@record');

    });
    /**
     * 配置信息获取接口
     */
    Route::group(['namespace' => 'Setting'], function () {
        //获取首页的轮播图信息
        Route::get('getHomeImageInfo', "SettingInfoController@getHomeImageInfo");
        //弹窗开关获取
        Route::get('getPopupSwitchInfo', "SettingInfoController@getPopupSwitchInfo");

        Route::get('getBannerImageInfo', "SettingInfoController@getBannerImageInfo");
        //获取首页的H5页面的信息
        Route::get('getHomeInsuranceInfo', "SettingInfoController@getHomeInsuranceInfo");
        //获取app端的提示语
        Route::get('hint/{type?}',"SettingInfoController@getHint");
        //获取app的一些借款配置信息
        Route::get("getLoanSetting", "SettingInfoController@getLoanSetting");
        Route::get("document/{type?}", "SettingInfoController@getDocument");
        //Route::get('getNoticeInfo/{type?}', "SettingInfoController@getNoticeInfo");
    });

    /*
     * 风控平台相关接口
     * */
    Route::group(['namespace' => 'Risk'],function(){
        //请求爬虫接口返回交易流水号
        Route::get('risk/spider',"RiskController@getSerialNum")->name('risk.spider');
        //申请风控
        Route::post('risk/apply',"RiskController@applyRisk")->name('risk.apply');
        //风控查询
        Route::get('risk/query',"RiskController@queryRiskResult")->name('risk.query');
        //爬虫状态
        Route::get('risk/spider/status','RiskController@spiderStatus')->name('risk.spider.status');

    });

    /**
     * 还款相关接口
     */
    Route::group(['namespace' => 'Repay'], function () {
        Route::put('repay', "RepayController@setMoneyRepay")->name('repay.put_repay');//发起还款
        Route::get('repay', "RepayController@getCurrentRepay")->name('repay.get_repay');//获取页面元素信息
        Route::get('confirm', "RepayController@confirmRepay")->name('repay.confirm');//成功失败按钮
        Route::get('repay/history', "RepayController@history")->name('repay.history'); //借款历史记录
        Route::get('repay/index', "RepayController@index")->name('repay.index'); //借款记录
        Route::get('repayment', "RepayController@getAllRepayMoney")->name('repay.repayment'); //全部结清试算
        Route::any('test', "TestRepayController@test")->name('repay.test'); //测试
    });

    /**
     * 消息
     */
    Route::group(['namespace' => 'Message'], function () {
        /**
         * 系统消息
         */
        Route::get('sysMessage','SysMessageController@index');
        Route::post('sysMessage/read/{msg}','SysMessageController@read');
        /**
         * 页面消息
         */
//        Route::get('headerMsg','HeaderController@show');
    });



    /**
     * 版本更新
     */
    Route::group(['namespace' => 'Update'], function () {
        Route::get('update', 'UpdateController@index')->name('update.index');
    });

    /**
     * APP公共路由
     */
    Route::group(['namespace'=>'Common'],function(){
        /**
         * 上传文件
         */
        Route::post('file/upload','FileController@upload');
        /**
         * 获取信息选项
         */
        Route::get('infoSelection','InfoSelectionController');

        /**
         * 获取下载地址
         */
        Route::get('download-list','DownloadLinkController@list');
    });

    Route::group(['namespace'=>'Shop'],function(){
        Route::get('shop/token','TokenController@getTokenByUserId');
    });

    /**
     * 手机检测提供注册ID和时间
     */
    Route::group(['namespace'=>'PhoneCheck'],function(){
        Route::get('phone/{phone_num?}','PhoneCheckInfoController@phoneCheck');
    });


    //因为联登访问人数较多，超出每秒访问频率限制，重新定义路由，不走该频率限制中间件
    /*
    Route::group(['namespace'=>'UnionLogin','prefix'=>'union_login'],function(){
        Route::get('fish','FishController@index'); //小黑鱼撞库
        Route::post('fish_register','FishController@pusherInfo'); //小黑雨注册

        Route::get('pro_index','ProvincialController@index');//省呗 测试
        Route::post('pro_index_register','ProvincialController@index_register');//省呗 注册生成密钥
        Route::post('pro_check','ProvincialController@check');//省呗 验证是否撞库
        Route::post('pro_user_register','ProvincialController@user_register');//省呗注册新用户

        Route::get('gather_index','GatherController@index');//聚好贷 测试
        Route::post('gather_check','GatherController@check');//聚好贷 验证是否撞库
        Route::post('gather_register','GatherController@user_register'); //聚好贷 注册新用户

        Route::get('wycard_index','WycardController@index');//51信用卡 测试
        Route::post('wycard_check','WycardController@check');//51信用卡 验证是否撞库
        Route::post('wycard_register','WycardController@user_register'); //51信用卡 注册新用户

        Route::post('yqg_test_hit','PiggyBankController@test_hit');//洋钱罐 测试
        Route::post('yqg_test_register','PiggyBankController@test_register');//洋钱罐 注册生成密钥
        Route::post('yqg_check','PiggyBankController@check');//洋钱罐 验证是否撞库
        Route::post('yqg_register','PiggyBankController@register'); //洋钱罐 注册新用户

        Route::post('baojie_test_hit','BaoJieController@test_hit');//保街 验证是否撞库
        Route::post('baojie_test_register','BaoJieController@test_register'); //保街 注册新用户
        Route::post('baojie_check','BaoJieController@check');//保街 验证是否撞库
        Route::post('baojie_register','BaoJieController@register'); //保街 注册新用户
    });
   */

});

Route::group(['namespace'=>'UserFollow\V10', 'prefix' => 'v10'],function(){
    Route::post('userfollow', 'UserFollowController@store')->name('userfollow');
    Route::post('userfollow_two', 'UserFollowController@store_two')->name('userfollow_two');

    Route::post('source-count','SourceCountController@store');
});

//被调
Route::group(['namespace'=>'Collection', 'middleware' => 'app_important_maintain'],function(){
    Route::post('withholding','WithholdingController@withholding')->name('collection.withholding');
    Route::post('repayment','RepaymentController@repayment')->name('collection.repayment');
    //Route::post('withhold', 'WithholdingController@withHold')->name('collection.withHold');//新的代替withholding
    /**
     * 商户代偿（销帐）接口
     */
    Route::post('writeoff', 'PayCompensateController@store')->name('collection.writeoff');

    /**
     * 申请减免
     */
    Route::post('repayrelief/add', 'RepayReliefController@add')->name('collection.repayrelief.add');

});

#免除开关控制的路由
Route::group(['namespace' => 'Frontend\V10', 'prefix' => 'v10'], function () {
    Route::group(['namespace' => 'Auth'], function () {
        //注册
        Route::post('register', 'RegisterController@register')->name('api_v10.register');
        //登录
        Route::post('login', 'LoginController@login')->name('api_v10.login');
        //注销
        Route::get('logout', 'LoginController@logout');
    });

    Route::group(['namespace' => 'Users'], function () {
        // 获取用户基础信息
        Route::get('me', 'UserController@me');
    });

    /**
     * 消息
     */
    Route::group(['namespace' => 'Message'], function () {
        /**
         * 页面消息
         */
        Route::get('headerMsg','HeaderController@show');
        Route::get('newMsg','NewsMessageController@list');
        Route::get('headerMsgList','HeaderController@index');
        Route::post('headerMsgRead','HeaderController@msgRead');
        Route::post('msgAllRead','HeaderController@msgAllRead');
    });
});


Route::get('test','TestController@test');
Route::any('testtest','TestController@testtest');

